package com.gxa.admin.controller;

import com.gxa.admin.entity.vo.ShopApplyVo;
import com.gxa.admin.param.ShopApplyParam;
import com.gxa.admin.param.ShopParam;
import com.gxa.admin.service.ShopApplyService;
import com.gxa.o2o.core.dto.ResultDTO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 蔚枫
 * @version 1.0
 * Talk is cheap. Show me the code
 * @description
 * @date 2021/7/21 10:02
 */
@RequestMapping("shopApply")
@RestController
@Api(tags = "后台----商家申请审核管理")
@ApiResponses({
        @ApiResponse(code=400,message="请求参数不完整或者错误"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=405,message="请求方式不正确，比如后台接收是post，但前端请求的是get"),
        @ApiResponse(code=406,message="页面地址和接口名冲突"),
        @ApiResponse(code=415,message="请求格式不正确，前端可能没有把请求头修改为json，也可能前端请求的json对象没有转换为字符串"),
        @ApiResponse(code=500,message="后台服务逻辑错误")
})
public class ShopApplyController {
    @Autowired
    private ShopApplyService shopApplyService;

    @ApiOperation(value = "根据id查询单个店铺申请详情")
    @PostMapping("/selectOne")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "id",value = "要查询的id",required = true,dataType = "int"),
    })
    public ResultDTO findByOne(@RequestParam("id") Long id){
        return shopApplyService.queryById(id);
    }

    @ApiOperation(value = "查询所有申请的店铺（包含未审核的，通过的放后面，未通过的在前面)")
    @PostMapping("/listAll")
    /*@ApiImplicitParams({@ApiImplicitParam(
            value = "查询所有申请的店铺",
            name = "listAll",
            dataType = "ShopApplyParam",
            required = true,
            paramType = "body"
    )})*/
    public ResultDTO listAll(@RequestBody ShopApplyParam shopApplyParam){
        return shopApplyService.findByAll(shopApplyParam);
    }
    @ApiOperation(value = "审批店铺")
    @PostMapping("/update")
    public ResultDTO update(@RequestBody ShopApplyVo shopApplyVo){
        return shopApplyService.update(shopApplyVo);
    }
}
